package com.ribbon.user;

import com.ribbon.User;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * Created by wangjing on 2018/7/27.
 */
public class UserServiceImpl implements UserService {

    @Autowired
    private RestTemplate restTemplate;


    @Override
    public User find(Long id) {
        return restTemplate.getForObject
                ("http//user-service/users/{1}",User.class,id);
    }

    @Override
    public List<User> findAll(List<Long> ids) {
        return restTemplate.getForObject
                ("http//user-service/users?ids={1}",List.class, StringUtils.join(ids,","));
    }
}
